package cn.jinshengda.controller;


import cn.jinshengda.Dto.Daily;
import cn.jinshengda.entity.DailyPaper;
import cn.jinshengda.service.DailyPaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.text.SimpleDateFormat;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-01-08
 */
@RestController
@CrossOrigin
public class DailyPaperController {

    @Autowired
    private DailyPaperService dailyPaperService;

    /*
     * @Author Lxy
     * @Description //TODO 添加员工每月日报
     * @Param  employeeId 添加的员工id daily 提交的月份,每月应交实交份数
    */
    @PostMapping("daily/add/{dailyId}")
    public void addDailyPaper(@PathVariable("dailyId") Integer employeeId, @RequestBody Daily daily){

        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM");
        String time = format.format(daily.getMonth());


        DailyPaper dailyPaper = new DailyPaper();
        dailyPaper.setEmployeeId(employeeId);
        dailyPaper.setCount(daily.getDue());
        dailyPaper.setCounted(daily.getRealCross());
        dailyPaper.setTime(time);
        dailyPaperService.save(dailyPaper);
    }
}

